package com.ruoyi.project.kafka;

import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class KafkaProducer {
    @Resource
    private KafkaTemplate<String, Object> kafkaTemplate;

    @PostMapping("/kafka/test")
    public void sendMessage(@RequestBody String msg) {
        kafkaTemplate.send("devices_cb6d8e7a1f_events", msg);
    }
}

